锘縱ar win = $(window), nav_on = null; $(function () { // 瀵艰埅鏍忔帶鍒 (function () { var nav = $('#nav'), shop = $('#shop'), // search_box = shop.find('#searchbox'), // search_btn = shop.find('.btn-search')[0], lis = nav.children(), lis_1 = lis.filter(':not(.more)'), lis_2 = lis.filter('.more'), links = lis.children(), links_1 = lis_1.children(), links_2 = lis_2.children(), subNav = $('#subNav'), subitem = $('#subNav').find('.item'), prev_item = $(), spans = links.children(), offs = spans.filter('.off'), ons = spans.filter('.on'), sbs = spans.filter('.slideBlock'), hei = links.eq(0).height(), len = lis.length, // 璁板綍褰撳墠 link_page = null, link_curr = null, timeout = -1; // 鍒濆鍖栧綋鍓嶉摼鎺 href = GetUrlRelativePath(); // 闈欐€侀〉闈㈢敤 // href = location.href, // 绋嬪簭鐢 for (var i = 0; i < len; i++) { link_page = links.eq(i); ; //nav_on = link_curr = link_page = link_page[0]; // if (href.indexOf(link_page.attr('href').replace(/(?:_\d)?\..*/, '')) > 0) { // 闈欐€侀〉闈㈢敤 // if (href.indexOf(link_page.attr('href').replace(/(?:_\d)?\..*/, '')) > 0) { // 绋嬪簭鐢 if(href == link_page.attr('href')){ control(nav_on = link_curr = link_page = link_page[0], false); delete i; break; } } links_2.each(function (idx) { if (this === nav_on) return; this.setAttribute('idx', idx); }); if (i === len) { if (href.indexOf('/user') >= 0) { control(nav_on = link_curr = link_page = links.eq(5)[0], false); } else { control(nav_on = link_curr = link_page = links.eq(0)[0], false); } } win.on('load', function () { // 榧犳爣鎸囧悜, 閾炬帴楂樹寒 links_1.hover(function () { control(this, false) }, none); links_2.hover(function () { control(this, true) }, none); // 榧犳爣绂诲紑瀵艰埅鏍? 鎭㈠褰撳墠椤甸潰楂樹寒 nav.hover(none, function () { timeout = setTimeout(function () { control(link_page, false); }, 10); }); subNav.hover(function () { clearTimeout(timeout); }, function () { control(link_page, false); }); }); function control(elem, flag, idx) { link_curr.className = ""; elem.className = "on"; link_curr = elem; prev_item.removeClass('on'); if (flag) { idx = parseInt(elem.getAttribute('idx')); prev_item = subitem.eq(idx).addClass('on'); // search_box.hide(); // search_btn.className = "btn-search"; } } function GetUrlRelativePath() 銆€銆€{ 銆€銆€銆€銆€var url = document.location.toString(); 銆€銆€銆€銆€var arrUrl = url.split("//"); 銆€銆€銆€銆€var start = arrUrl[1].indexOf("/"); 銆€銆€銆€銆€var relUrl = arrUrl[1].substring(start);//stop鐪佺暐锛屾埅鍙栦粠start寮€濮嬪埌缁撳熬鐨勬墍鏈夊瓧绗 銆€銆€ 銆€銆€銆€銆€return relUrl; 銆€銆€} function none() { } // 2015.06.09 淇敼鎼滅储, 娣诲姞璇█ var subitem_search = subitem.filter('.search'), subitem_langs = subitem.filter('.langs'); subitem_nwmenu = subitem.filter('.nwmenu'); shop.find('.btn-search').hover(function () { prev_item.removeClass('on'); prev_item = subitem_search.addClass('on'); }, none); shop.find('.btn-lang').hover(function () { prev_item.removeClass('on'); prev_item = subitem_langs.addClass('on'); }, none); $('.more-quanwang').hover(function () { prev_item.removeClass('on'); prev_item = subitem_nwmenu.addClass('on'); }, none); shop.hover(none, function () { timeout = setTimeout(function () { prev_item.removeClass('on'); }, 300); }); subitem_nwmenu.on('mouseleave',function(){ prev_item.removeClass('on'); }) }()); // 鎼滅储鎸夐挳 (function () { var sup = $('#header'), btn = sup.find('.btn-search'), box = sup.find('#searchbox'), timeout = -1, delay = 1000; btn.hover(open, autoFade); box.on('focus', function () { clearTimeout(timeout); }).on('blur', function () { autoFade(); }); function open() { clearTimeout(timeout); btn.addClass('on'); box.stop(false, true).fadeIn(300); } function close() { btn.removeClass('on'); box.stop(false, true).fadeOut(300); } function autoFade() { timeout = setTimeout(function () { close(); }, delay); } }()); // placeholder 澶勭悊 (function () { // 鎯呭喌1锛屽鏋滄祻瑙堝櫒鏀寔 placeholder锛屽垯浼樺厛浣跨敤榛樿銆 var input = document.createElement("input"); input.type = "text"; if ("placeholder" in input) return; // 鎯呭喌2锛屽鏋滄病鏈変换浣曟爣绛句娇鐢 placeholder锛屽垯涓嶅仛浠讳綍澶勭悊銆 var inputs = $("*[placeholder]"), val = ""; if (!inputs.length) return; // 鎯呭喌3锛屽浜庝笉鏀寔 placeholder 灞炴€х殑鍏冪礌杩涜棰勫姞杞藉拰浜嬩欢鎸傝浇銆 inputs .each(function () { input = $(this); input.val(input.attr("placeholder")); }) .on("focus", focus) .on("blur", blur) .on("change", change); // 澶勭悊鍑芥暟 function focus() { input = $(this); val = input.val(); if (val && (val !== input.attr('placeholder'))) return; else input.val(""); } function blur() { // input.val(input.attr("placeholder")); val = input.val(); if (val && (val !== input.attr('placeholder'))) { return; } else { input.val(input.attr("placeholder")); } } function change() { if (input.val()) { input.off("focus").off("blur"); } else { input.on("focus", focus).on("blur", blur); } } })(); // 娉曞緥澹版槑 & 缃戠珯鍦板浘 鍞ゅ嚭 (function () { var copyright = $('#copyright'), btn_legal = copyright.find('.legal'), btn_map = copyright.find('.sitemap'), mask = $('#mask'), wraps = mask.find('.wrap'), legal = wraps.filter('#legal'), map = wraps.filter('#sitemap'), curr = $(), body = $(document.body), m_left = (win.width() - body.width()) / 2; win.on('resize', function () { m_left = (win.width() - body.width()) / 2; body.css('margin-left', m_left); }); btn_legal.on('click', function () { open(legal); }); btn_map.on('click', function () { open(map); }); mask.on('click', close); function open(elem) { mask.show() curr = elem.animate({ 'right': 0 }, 189); body.stop().animate({ 'margin-left': m_left - 378 }, 189); } function close() { curr.stop().animate({ 'right': -378 }, 189, function () { mask.hide(); }); body.stop().animate({ 'margin-left': m_left }, 189); } // wraps.on('click', function (e) { // if (e && e.stopPropagation) { // e.stopPropagation(); // } else window.event.cancelBubble = true; // // return false; // }); }()); // 璋冩暣楂樺害 (function () { var copyright = $('#copyright'), hei = $('html').height() - $('body').height(); if (hei <= 0) return; copyright.find('.g-wrap div').height(37 + hei); }()); });